<!doctype html>
<html>
<meta charset=utf8>
<head>
<script src="jquery-1.6.4.min.js"></script>
<script src="enchant.js"></script>
<script>
enchant();
$(function(){
	var game = new Game(320, 320);
	game.preload("numbers.gif");
	game.onload=function(){
		var stage = new Group();
		
		var nary = new Group();
		nary.n = [];
		var size = 16;
		for (var i = 0; i < 10; i++) {
			var n = new Sprite(32, 32);
			n.x = i * size;
			n.y = 0;

			n.scale(size/32);
			n.x -= 32/2 - size/2;
			n.y -= 32/2 - size/2;

			n.image = game.assets["numbers.gif"];
			n.frame = 0;
			nary.addChild(n);
			nary.n[i] = n;
		}
		stage.addChild(nary);
		nary.num = function(n) {
			$.each(this.n, function(i, n) {
				n.frame = 0;
			});
			var i = 0;
			while(n > 0) {
				this.n[9 - i].frame = n % 10;
				n = Math.floor(n / 10);
				i++;
			}
		};
		
		nary.addEventListener(Event.ENTER_FRAME, function(e) {
			this.num(game.frame);
		});
		game.rootScene.addChild(stage);
	};
	game.start();
});
</script>
<body style="margin:0">
